/**
 * Created by liutong on 17/6/17.
 */

export function pingImg(url, callback) {
    const img = new Image();
    let done;
    const finish = (status) => {
        if (!done) {
            done = true;
            img.src = '';
            callback(status);
        }
    };
    img.onload = () => finish('responded');
    img.onerror = () => finish('error');
    img.src = url;
    return setTimeout(() => finish('timeout'), 1500);
}